package com.avcdata.national.adapter;

import android.content.Context;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.BaseAdapter;
import android.widget.ImageView;
import android.widget.TextView;


import com.avcdata.aoscustommade.R;

import java.util.List;
import java.util.Map;

/**
 * Created by Administrator on 2016/11/3.
 */

public class SelectedGridViewAdapter extends BaseAdapter {

    private List<Map<String, Object>> list;
    private Context context;

    public SelectedGridViewAdapter(List<Map<String, Object>> list, Context context) {
        this.context = context;
        this.list = list;
    }

    @Override
    public int getCount() {
        return list.size();
    }

    @Override
    public Object getItem(int position) {
        return list.get(position);
    }

    @Override
    public long getItemId(int position) {
        return position;
    }

    @Override
    public View getView(int position, View convertView, ViewGroup parent) {
        viewHolder holder;
        if (convertView == null) {
            convertView = LayoutInflater.from(context).inflate(R.layout.item_selectedproduct, null);
            holder = new viewHolder();
            holder.brandName = (TextView) convertView.findViewById(R.id.brandName);
            holder.deleteBrand = (ImageView) convertView.findViewById(R.id.deleteProduct);
            convertView.setTag(holder);
        } else {
            holder = (viewHolder) convertView.getTag();
        }

        holder.brandName.setText ( list.get ( position ).get ( "brandName" ).toString () );
        holder.deleteBrand.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {

            }
        });
        return convertView;
    }


    class viewHolder {
        TextView brandName;
        ImageView deleteBrand;
    }

}
